package com.lakeworks.common.enums;

import static java.util.Arrays.stream;

/**
 * 工厂订单类型标记（入场单 产品通用）
 */
public enum WorkType implements ValueEnum<WorkType> {


    /**
     * 转厂单
     */
    DIVERT(1 << 11),


    /**
     * 救治单
     */
    TREAT(1 << 12),


    /**
     * 返厂单
     */
    RETURN(1 << 13),

    /**
     * 回收单
     */
    RECYCLE(1 << 14);


    private int value;

    WorkType(int value) {
        this.value = value;
    }

    public static int sum() {
        return stream(values()).mapToInt(WorkType::value).reduce(0, (a, b) -> a | b);
    }

    public static WorkType[] explode(int value) {
        return stream(values()).filter(s -> (s.value() & value) == s.value()).toArray(WorkType[]::new);
    }

    @Override
    public int value() {
        return this.value;
    }


}
